package jcore.basic;

//测试几种访问控制，数据的封装性

public class Student {
	protected String only;
	//public String only;
	
	public String P = "P";
	
	

	private String name;
	/**
	 * @return the only
	 */
	public String getOnly() {
		return only;
	}

	/**
	 * @param only the only to set
	 */
	public void setOnly(String only) {
		this.only = only;
	}

	public long score; // public成员
	// private int age = 0; //私有成员
	public int age = 0;

	protected int s_p = 1;

	public Student() {

	}

	public Student(String name, long score, int age) {
		this.name = name;
		this.score = score;
		this.age = age;
		this.only = "Parent";
	}

	public Student(String name, long score) {
		this.name = name;
		this.score = score;
	}

	static long sum = 0;
	static long count = 0;

	public void total() {
		sum += score;
		count++;
	}

	// 未加访问控制符就是默认的包可见性，在其他package里面就不能调用该方法
	public static long average() {
		return sum / count;
	}

	// 公有方法访问私有属性
	public int getAge() {
		System.out.print("Student:  ");
		return age;
	}

	public String showMessage() {
		return "I am Parent!";
	}

	public void hello() {
		System.out.println("Parent say hello!");
	}
}
